package com.example.mylibrarybase.yumengmeng13.ui;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.mylibrarybase.R;
import com.example.mylibrarybase.bar.initAction_Bar;
import com.example.mylibrarybase.base.baseui.BaseActivity;
import com.example.mylibrarybase.utils.LogUtils;
import com.example.mylibrarybase.utils.UtilsToast;
import com.example.mylibrarybase.yumengmeng12.utils.UtilsSetManager;
import com.example.mylibrarybase.yumengmeng12.view.Myrecyclerview_12;
import com.example.mylibrarybase.yumengmeng13.adapter.cheboxRecyclerview;
import com.example.mylibrarybase.yumengmeng13.bean.item_j;

import java.util.ArrayList;

public class MainActivity_13_Recyclerviewchebox extends BaseActivity {

    private initAction_Bar mBase_action_bar;
    private Myrecyclerview_12 mRecyclerview_chebox_13;
    private ArrayList<item_j> mItem_js;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    @Override
    public int getlayouXML() {
        return R.layout.activity_main_13__recyclerviewchebox;
    }

    @Override
    public void initView() {
        mRecyclerview_chebox_13 = (Myrecyclerview_12) findViewById(R.id.recyclerview_chebox_13);
        mBase_action_bar = (initAction_Bar) findViewById(R.id.base_action_bar);
        mBase_action_bar.setMode(initAction_Bar.AUTO_ONCLICK_MODE)
                .setCallBack(new initAction_Bar.Action_bar_call_back() {
                    @Override
                    public void getAction_barView_backbutton(TextView textView) {

                    }

                    @Override
                    public void getAction_barView_backbutton_icon(ImageView imageView) {

                    }

                    @Override
                    public void getAction_barView_title(TextView textView) {
                        textView.setText("列表chebox");
                    }

                    @Override
                    public void getAction_barView_right_icon(ImageView imageView) {
                        imageView.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                ArrayList<String> strings = new ArrayList<String>();
                                for (int i = 0; i < mItem_js.size(); i++) {
                                    item_j item_j = mItem_js.get(i);
                                    if (item_j.tag==1){
                                        strings.add(item_j.t);
                                    }
                                }
                                UtilsToast.showToast(MainActivity_13_Recyclerviewchebox.this, strings+"勾选条目的条目有");
                            }
                        });
                    }
                });
        initData();
    }

    @Override
    public void initData() {
        mItem_js = new ArrayList<>();

        for (int i = 0; i <40; i++) {
            mItem_js.add(new item_j("条目"+i,0));

        }
        cheboxRecyclerview cheboxRecyclerview = new cheboxRecyclerview(this, mItem_js, new cheboxRecyclerview.Callback() {
            @Override
            public void oncheboxclick(int pos, int boolentag) {
                LogUtils.i("被点击的是"+pos+"状态是"+boolentag);
            }
        });
        UtilsSetManager.LinearLayoutManager(this, LinearLayoutManager.VERTICAL,mRecyclerview_chebox_13 );
        mRecyclerview_chebox_13.setAdapter(cheboxRecyclerview);

    }
}
